var http = require('http');
var url = require('url');
var router = require('./router');
var exception = require('./module/exception');

http.createServer(function(request, response) {
	if(request.url !== '/favicon.ico'){
		pathname = url.parse(request.url).pathname;
		pathname = pathname.replace(/\//, '');
		
		/* try {} catch(){} 异常捕获*/
		try {
			router[pathname](request, response);
		}catch(err){
			console.log("捕获的异常：" + err);
			response.writeHead(200, {'Content-Type': 'text/html; charset = utf-8'});
			response.write(err.toString());
			response.end('');
		}
		console.log("server 执行完毕");
	}
	
}).listen(8000);

console.log('server runing at http://192.168.178.7:8000');